import ApiService from './api';

export interface DashboardStats {
  totalOrders: number;
  totalRevenue: number;
  totalProfit: number;
  newUsers: number;
  trends: {
    orders: number;
    revenue: number;
    profit: number;
    users: number;
  };
}

export interface SalesTrendData {
  months: string[];
  sales: number[];
}

export interface RegionData {
  name: string;
  value: number;
  color: string;
}

export interface OrderStatsData {
  dates: string[];
  totalOrders: number[];
  abnormalOrders: number[];
}

class DashboardService {
  // 获取仪表板统计数据
  static async getDashboardStats(): Promise<DashboardStats> {
    const response = await ApiService.get<{ success: boolean; data: DashboardStats }>('/admin/dashboard/stats');
    return response.data;
  }

  // 获取销售趋势数据
  static async getSalesTrend(): Promise<SalesTrendData> {
    const response = await ApiService.get<{ success: boolean; data: SalesTrendData }>('/admin/dashboard/sales-trend');
    return response.data;
  }

  // 获取地区统计数据
  static async getRegionStats(): Promise<RegionData[]> {
    const response = await ApiService.get<{ success: boolean; data: RegionData[] }>('/admin/dashboard/region-stats');
    return response.data;
  }

  // 获取订单统计数据
  static async getOrderStats(): Promise<OrderStatsData> {
    const response = await ApiService.get<{ success: boolean; data: OrderStatsData }>('/admin/dashboard/order-stats');
    return response.data;
  }
}

export default DashboardService;
